package sword;

import java.util.Stack;

/**
 * @Author: 海琳琦
 * @Date: 2022/5/25 15:25
 */
public class Title09 {

    /**
     * 入
     */
    Stack<Integer> stack;

    /**
     * 出
     */
    Stack<Integer> stack1;

    public Title09() {
        stack = new Stack<>();
        stack1 = new Stack<>();
    }

    public void appendTail(int value) {
        stack.push(value);
    }

    public int deleteHead() {
        if (stack1.isEmpty() && stack.isEmpty()) {
            return -1;
        } else if (stack1.isEmpty()) {
            //将stack的元素放到stack1中
            int size = stack.size();
            for (int i = 0; i < size; i++) {
                stack1.push(stack.pop());
            }
        }
        return stack1.pop();
    }
}
